Repository navigation
Keep auto channel open from recommending swap providers the node swaps out through - #696
Conversation
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR blocks auto channel-open recommendations to Lightning nodes of swap providers (Loop, 40swap, Spark) that the node currently swaps out through, since its own swap-out payments would drain the new channel. The block list is derived from the same SwapProviderLimits.Weighted() that AutoLiquidityManagementJob uses to actually pick swap providers, so it cannot disagree with real swap routing; pubkey matching is case-insensitive against LND's canonical lowercase hex, so a peer cannot evade it; and the rejection runs before the reserved-peer and cooldown paths with already-open recommendations expiring on the next run via ProcessNode's existing finally block. All inputs to the new logic are operator-controlled (env-parsed pubkey lists) or admin-set (node swap weights) — I found no attacker-reachable path to bypass the check, crash the job, or extract anything.
Reviewed 10 files at 02c74fa. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the swap-provider exclusions in automatic channel recommendations.
No open issues 🎉
What changed in this PR
Prevents automatic channel recommendations to swap providers a node uses, including reserved peers, while leaving manual channel opens unchanged.
Changes:
- Adds configurable provider pubkey lists and rejects matching peers based on swap weights.
- Adds unit and end-to-end coverage for blocking providers and expiring recommendations.
- Updates documentation and UI guidance.
| File | Description |
|---|---|
| test/NodeGuard.Tests/Services/SwapOutWarningServiceTests.cs | Makes amount assertions culture-aware. |
| test/NodeGuard.Tests/Services/ChannelOpenInitiatorServiceTests.cs | Tests provider rejection, including reserved peers. |
| test/NodeGuard.Tests/Jobs/AutoChannelOpenJobTests.cs | Tests filtering by provider weights. |
| test/NodeGuard.Tests/E2E/AutoChannelOpenE2ETests.cs | Tests recommendation expiry and recovery after weight changes. |
| src/Services/SwapProviderLimits.cs | Maps active providers to their node pubkeys. |
| src/Services/ChannelOpenInitiatorService.cs | Rejects swap providers before other peer checks. |
| src/Pages/Nodes.razor | Clarifies reserved-peer exclusions. |
| src/Jobs/AutoChannelOpenJob.cs | Adds provider identity to peer snapshots. |
| src/Helpers/Constants.cs | Defines provider pubkeys and environment overrides. |
| docs/auto-channel-open.md | Documents provider exclusions and configuration. |
| docker/e2e/nodeguard-entrypoint.sh | Configures Carol as the test swap provider. |
Review effort: Balanced
…e swaps out through
02c74fa to
766e73e
Compare
There was a problem hiding this comment.
🔒 Automated security review — no issues found
This PR adds a deny-list to the auto channel-open planner: peers whose pubkey appears in the LOOP/FORTYSWAP/SPARK node-pubkey sets are rejected as channel-open recommendations when the node gives that provider any swap weight. The change is purely subtractive — it removes recommendations, never adds or authorizes anything new — and the only inputs are admin-set environment variables (parsed at startup in Constants) and the node's own database weights, none of which an unauthenticated or low-privilege attacker controls. The pubkey lists are compared case-insensitively over full 33-byte pubkeys, so no injection or partial-match path exists. No exploitable defect found.
Reviewed 6 files at 766e73e. Nothing to report.
Not a guarantee — one diff, no knowledge of your threat model.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
Auto channel open could recommend a channel to a swap provider the node itself swaps out through. Our swap-outs are our own payments to that provider, so they would drain the new channel as soon as it opened, and we would pay to open it for nothing.
A node now gets no recommendation to a Loop, 40swap or Spark node while it gives that provider any swap weight, however small. The check runs before every other one and applies to reserved peers too. A provider the node gives no weight is treated like any other peer, and a recommendation already open to a blocked peer expires on the next run. Channel opens created by hand are not stopped.
Provider nodes are listed by pubkey in LOOP_NODE_PUBKEYS, FORTYSWAP_NODE_PUBKEYS and SPARK_NODE_PUBKEYS. Loop and Spark default to their mainnet nodes; 40swap has no default, so it is not blocked until its nodes are listed. Setting a variable replaces its default.
Covered by unit tests and a new e2e scenario, where carol stands in for a 40swap node. The docs no longer present a swap service as the typical reserved peer.
Stack created with GitHub Stacks CLI • Give Feedback 💬